package com.wlr.blog.util.common.enums;

import lombok.Getter;

/**
 * @author lrwang
 * @version 1.0
 * @date 2022/11/14 21:37
 */
@Getter
public enum SearchStrategyEnum {
    /**
     * 搜索类型
     * mysql
     */
    MYSQL_SEARCH("mysql", "mysqlServiceImpl"),
    /**
     * 搜索类型
     * es
     */
    ES_SEARCH("es", "esServiceImpl");
    /**
     * 搜索类型
     */
    private String searchType;
    private String strategy;

    SearchStrategyEnum(String searchType, String strategy) {
        this.searchType = searchType;
        this.strategy = strategy;
    }

    /**
     * 获取策略
     *
     * @param searchType 模式
     * @return {@link String} 搜索策略
     */
    public static String getStrategy(String searchType) {
        for (SearchStrategyEnum value : SearchStrategyEnum.values()) {
            if (value.getSearchType().equals(searchType)) {
                return value.getStrategy();
            }
        }
        return null;
    }
}
